﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MultipleBooking
{
    class CountWindow : Form
    {
        Label roomLabel;
        TextBox roomTextBox;
        Label userLabel;
        TextBox userTextBox;
        Label requestLabel;
        TextBox requestTextBox;
        Label seedLabel;
        TextBox seedTextBox;
        Button generateButton;

        public int RoomCount;
        public int UserCount;
        public int RequestCount;
        public int SeedCount;

        public CountWindow()
        {
            this.StartPosition = FormStartPosition.CenterParent;

            roomLabel = new Label()         { Left = 0, Top = 0, Text = "Rooms" };
            userLabel = new Label()         { Left = 0, Top = 30, Text = "Users" };
            requestLabel = new Label()      { Left = 0, Top = 60, Text = "Requests" };
            seedLabel = new Label()         { Left = 0, Top = 90, Text = "Random Seed" };
            roomTextBox = new TextBox()     { Left = 100, Top = 0, Text="2" };
            userTextBox = new TextBox()     { Left = 100, Top = 30, Text="2" };
            requestTextBox = new TextBox()  { Left = 100, Top = 60, Text="4" };
            seedTextBox = new TextBox()     { Left = 100, Top = 90, Text="0" };
            generateButton = new Button()   { Left = 0, Top = 120, Text = "Generate" };
            generateButton.Click += new EventHandler(generateButton_Click);
            this.Width = 220;
            this.Height = 190;
        }

        void generateButton_Click(object sender, EventArgs e)
        {
            RoomCount = int.Parse(roomTextBox.Text);
            UserCount = int.Parse(userTextBox.Text);
            RequestCount = int.Parse(requestTextBox.Text);
            SeedCount = int.Parse(seedTextBox.Text);
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
        protected override void OnLoad(EventArgs e)
        {
            AddControls(roomLabel, userLabel, requestLabel, roomTextBox, userTextBox, requestTextBox, seedLabel, seedTextBox, generateButton);
        }
        private void AddControls(params Control[] input)
        {
            foreach (var c in input)
            {
                this.Controls.Add(c);
                c.Top += 8;
                c.Left += 4;
            }
        }
    }
}
